#include <iostream>

#include "consts.h"
#include "io.h"
#include "MonteCarlo.h"


/*
	a chess board is represented by two integers;
	one representing the x-side
	the other representing the o-side

	0 representing the o-player
	1 representing the x-player
*/



/*
	function:			read a 4x4 chess board, ouput a chess board with the optimal move dropped

	note:				assume x is the next to operate
*/
int main()
{
	char chess[4][4] = { 0 };

	while (1)
	{
		get_board(chess);

		int chess_x, chess_o;
		convertArrayToInt(chess, chess_x, chess_o);

		node * root = generateNewNode();
		initializeNode(root);
		root->chess_o = chess_o;
		root->chess_x = chess_x;
		root->move = XPLAYER;
		root->visit = 1;
		
		uct(root);
		//myDummyAlg(root);
		node * optimal = findOptimalNode(root);
		print_board(optimal->chess_x, optimal->chess_o);
		putchar('\n');

		freeNodeMemory(root);
	}
}